package com.example.foo.admin.web.member;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import com.ruoyi.common.core.domain.AjaxResult;
import com.example.core.PageResult;
import com.example.core.Pageable;
import com.example.foo.member.model.MemberIdcard;
import com.example.foo.member.query.MemberIdcardQuery;
import com.example.foo.member.service.MemberIdcardService;

@org.springframework.web.bind.annotation.RestController
public class MemberIdcardAction {

	private final MemberIdcardService memberIdcardService;

	public MemberIdcardAction(MemberIdcardService memberIdcardService) {
		this.memberIdcardService = memberIdcardService;
	}

	@GetMapping("/api/memberidcards")
	public AjaxResult index(MemberIdcardQuery memberIdcardQuery, Pageable pageable) {
		PageResult<MemberIdcard> pageResult = memberIdcardService.findMemberIdcards(memberIdcardQuery, pageable);
		return AjaxResult.successData(pageResult);
	}

	@GetMapping("/api/memberidcards/{id}")
	public AjaxResult showMemberIdcard(@PathVariable("id") Long id) {
		MemberIdcard memberIdcard = memberIdcardService.findMemberIdcardById(id);
		if (memberIdcard == null) {
			return AjaxResult.error(404, "Not Found");
		}
		return AjaxResult.successData(memberIdcard);
	}

}
